import db from '../db/index.js'
export function setaedit(req,res){
        const {adminid,val,type,title} = req.body
        const time = new Date()
        const sql='insert into aedit set adminid =?,val=?,type=?,create_time =?,title=? '
        db.query(sql,[adminid,val,type,time,title],(err,data)=>{
            if(err)  return res.dbno(err)
                res.send({status:200,data})
        })
}
export function getaedit(req,res){
    const sql ='select editid,val,type,create_time,title from aedit'
    db.query(sql,(err,data)=>{
        if(err) return res.dbno(err)
            res.send({status:200,data})
    })
}
export function settedit(req,res){
        const {teacherid,val,type,title} = req.body
        console.log(teacherid);
        
        const time = new Date()
        const sql='insert into tedit set teacherid =?,val=?,type=?,create_time =?,title=? '
        db.query(sql,[teacherid,val,type,time,title],(err,data)=>{
            if(err)  return res.dbno(err)
                res.send({status:200,data})
        })
}
export function gettedit(req,res){
    const {teacherid }=req.query
    const sql ='select editid,val,type,create_time,title,teacherid from tedit where teacherid =?'
    db.query(sql,teacherid,(err,data)=>{
        if(err) return res.dbno(err)
            res.send({status:200,data})
    })
}